473,426 Members | 1,519 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,426 software developers and data experts.

cascading dropdown menus

1
Hello everyone:
I need to make a dropdown menu that shows information depending on what the user chooses in the first one. I am using PHP and MySql.
I am new!

I looked for tutorials and I am trying to understand the code... however it is not clear enough. I will say what I understand so you can tell me where I am wrong.
Expand|Select|Wrap|Line Numbers
  1. <?PHP      
  2. require_once('connection.php');
  3. require_once('open_db.php');
  4.  
  5. $query1=mysql_query("SELECT Route_From as Desde FROM route") or die(mysql_error());
  6. $query2=mysql_query("SELECT * FROM route WHERE Route_From=".$_POST["Desde"]."&quot;") or die(mysql_error());
  7. ?>
  8.  
  9. <form name="check" method="post">
  10.    <!-- First Drop Down starts here -->
  11.       <select name="select1" onchange="this.form.submit()">
  12.          <?PHP
  13.             while ($row = mysql_fetch_assoc($query1)) 
  14.             {
  15.                 echo ("<option>{$row['Route_From']}</option>");
  16.             }
  17.           ?>
  18.       </select>
  19.  
  20.    <?PHP
  21.       if (isset($_POST["select1"]))
  22.    ?>
  23.    <select name="select2">
  24.    <?PHP
  25.       while($row = mysql_fetch_assoc($query2))
  26.       {
  27.          echo("<option>{$row['Route_To']}</option>");
  28.       }
  29.    ?>
  30.    </select>
  31. </form>
  32.  
Ok, so what I understand is:
- I connect to MySql (that works fine)
- I create the queries
- I create the first menu and start filling it up and with the "onchange", when a user selects an option, what he chose is submitted.
- When the first option is submitted, this info is captured with:
<?PHP
if (isset($_POST["select1"]))
?>
- The the second query is done and the second menu is filled.

When I execute the page the error that is shown is the following:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"' at line 1

I hope someone can help me!
Bye
May 2 '07 #1
6 3681
ak1dnar
1,584 Expert 1GB
Replace this line and let me know the status.

[PHP]$query2=mysql_query('SELECT * FROM route WHERE Route_From='.$_POST['Desde'].'') or die(mysql_error());[/PHP]
May 3 '07 #2
Just replace your $query2 line with this :

$query2=mysql_query("SELECT * FROM route WHERE Route_From='".$_POST["Desde"]."'") or die(mysql_error());
May 4 '07 #3
wish
65
Hello,
I had faced same problem..if user select the item in <select> then the below got one textarea to display the description of item..what should i write the code..

from <select> i retrieve all the item from db and then i want based on the user select the item then show the description of the item that what user was selected..

Can some one guide me...
May 15 '07 #4
ak1dnar
1,584 Expert 1GB
wish,
After getting the result set row values print it in side the teaxarea.

[PHP]<textarea name="description" cols="5" rows="5"><? echo $the_description ?></textarea>[/PHP]
May 15 '07 #5
wish
65
Thank you my friend...
One problem is settle but another problem prompt out..
because based on the above example, the <form name="change" method="post"> the action property is no use then when i click button to submit..it can not work..if i add action property in the form tag then when i select the item then it direct go to another page...then what should i write the code...

Can you guide me again..
May 15 '07 #6
ak1dnar
1,584 Expert 1GB
Thank you my friend...
One problem is settle but another problem prompt out..
because based on the above example, the <form name="change" method="post"> the action property is no use then when i click button to submit..it can not work..if i add action property in the form tag then when i select the item then it direct go to another page...then what should i write the code...

Can you guide me again..
Its better to post a new thread for this question,Its not a good idea to continue with this tread here after.because this is not related to the thread of yo123.
May 15 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Humpty Dumpty | last post by:
Hi folks, here's a challenge: I have a dynamically created cascading menu in Tkinter that can be quite large because it is created from a file. I tried using lazy creation so only the menu item...
3
by: michelle | last post by:
Hi all, I am new to Tk, or Python GUI programming and I seem to be stuck. I have looked about for help with Tk GUIs, but everything seems so terse or incomplete?? I have been mostly using the...
19
by: chart43 | last post by:
I have question about the technique for css dropdown menus described in http://www.alistapart.com/articles/horizdropdowns/. Based on an html list, it has a few items in a 1st order list and further...
7
by: Marci | last post by:
I found this script for cascading menus, however, I cannot reach the author to solve the bug I am having when I add a second menu to it. My problem is this: If I click on the first link, the...
1
by: Cindy Lee | last post by:
is it possible to have cascading menus like: http://www.cracky.net/JAVA/Navigation/cascading-menu.html With scrollbars added, so you can only see a few options at a time? On some of my options...
2
by: Ian | last post by:
Can anyone help me with a problem I have. What I need to be able to do is have the user presented with a single dropdown menu within a form using HTML <SELECT> and <OPTION>. Once they choose a...
1
by: JMosey | last post by:
Not sure if this has been covered ( a google search came up pretty bare). I have a site that: - has multi-level cascading menus - floats center of the browser window - Will have fairly heavy...
0
by: acadam | last post by:
Hi, I am trying to use cascading dropdown but I have some problems. The firts dropdown is ok, it's filled regularly... but the second dropdown is still disabled!! Why? I tried to start my...
3
kcdoell
by: kcdoell | last post by:
I have 5 cascading combo boxes on a form. Below is a sample of my vb in the first combo box: Private Sub CboDivision_AfterUpdate() 'When the Division is selected, the appropriate Segment...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.